<template>
  <div>
    <div class="header">
      <van-nav-bar
        title="充值界面"
        left-text="返回"
        left-arrow
        @click-left="onClickLeft"
      />
    </div>
    <!-- {{this.$route.query}} -->
    <van-field
      type="number"
      placeholder="请输入充值金额"
      clearable
      @click="showHandler"
      :value="keyboardInput"
      v-model="keyboardInput"
    >
    </van-field>
    <van-button type="primary" block @click="rechage(keyboardInput)"
      >充 值</van-button
    >
    <van-number-keyboard
      :show="show"
      theme="custom"
      extra-key="."
      @blur="show = false"
      close-button-text="完成"
      @delete="onDelete"
      v-model="keyboardInput"
      type="number"
    />
  </div>
</template>

<script>
import { get, post } from "@/http/axios";
export default {
  data() {
    return {
      // 键盘显示
      show: false,
      //键盘输入内容
      keyboardInput:"",
      //用户所有数据
      // userAll:this.$route.query,
    };
  },
  methods: {
    // 键盘删除按钮
    onDelete() {},
    // 返回按钮
    onClickLeft() {
      this.$router.push({
        path: "/manager/mine",
      });
    },
    // 关闭键盘函数
    CloseKeyboard() {
      this.show = false;
    },
    //展示键盘
    showHandler() {
      this.show = true;
    },
    //充值按钮
    async rechage(userid, keyboardInput) {
      // this.userid=this.$route.query
      if (this.keyboardInput <= 0) {
        this.$toast.fail("输入的金额要大于0");
      } else if (this.keyboardInput > 1000) {
        this.$toast.fail("单次输入的金额不能大于1000");
      } else {
        let obj = {
          customerId:this.$route.query.customerId,
          money:Number(this.keyboardInput),
          
        };
        // console.log(obj);
        let res = await get("/account/recharge", obj);
        console.log(res);
        this.$toast.success("充值成功");
        this.$router.push({
          path:'/manager/mine'
        })
      }
    },
  },
  created() {
  },
};
</script>

<style scoped>
</style>